package com.hnucm.cooklife.base;

import androidx.appcompat.app.AppCompatDelegate;

import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.Utils;
import com.hnucm.cooklife.base.utils.BGAGlideImageLoader490;
import com.hnucm.cooklife.base.utils.Constant;
import com.kingja.loadsir.core.LoadSir;

import org.litepal.LitePal;
import org.litepal.LitePalApplication;

import cn.bingoogolapple.photopicker.imageloader.BGAImage;

public class CooklifeApplication extends LitePalApplication {
    @Override
    public void onCreate() {
        super.onCreate();
        LitePal.initialize(this);
        Utils.init(this);
        initMode();
        BGAImage.setImageLoader(new BGAGlideImageLoader490());
        LoadSir.beginBuilder()
                .addCallback(new ErrorCallback())
                .commit();
    }

    private void initMode() {
        boolean isNightMode = SPUtils.getInstance(Constant.CONFIG_SETTINGS)
                .getBoolean(Constant.KEY_NIGHT_MODE,false);
        AppCompatDelegate.setDefaultNightMode(isNightMode ? AppCompatDelegate.MODE_NIGHT_YES :
                AppCompatDelegate.MODE_NIGHT_NO);
    }
}
